{include file="public/header" /}
<body style="margin-top:30px;font-size:16px;">
	<div class="container">
		<div class="row clearfix">
			<form role="form" class="col-md-12" action="/index.php/index/my/teacher_json" method="post">
				<div class="form-group">
					<label for="school_name">企业(学校)名</label>
					<input type="text" class="form-control" id="school_name" value="{$find['school_name']}" {$find['status']==2?'disabled':''}/>
				</div>
				<div class="form-group">
					<label for="name">联系人</label>
					<input type="text" class="form-control" id="name" value="{$find['name']}" {$find['status']==2?'disabled':''}/>
				</div>
				<div class="form-group">
					<label for="phone">联系手机</label>
					<input type="text" class="form-control" id="phone" value="{$find['phone']}" {$find['status']==2?'disabled':''}/>
				</div>
				{if($find['status'] == 2)}
					<div class="form-group">
						<label for="phone">状态</label>
						<input type="text" class="form-control" id="phone" value="待审核" disabled/>
					</div>
				{/if}
				<div class="form-group">
					<label for="license">证件</label><br/>
					{if($find['status'] != 2)}
						<button type="button" class="btn btn-danger" id="up">上传</button><br/>
					{/if}
					<div id="demo" style="position:relative; width:100px; float:left; margin:0 10px 10px 0;">
						<img style="width:100px;height:100px;" src="{$find['license']}" class="layui-upload-img">
						<input type="hidden" id="license" value="{$find['license']}"/>
					</div>
				</div>
				{if($find['status'] != 2)}
					<button type="button" class="btn btn-block btn-success" id="submit">申请</button>
				{/if}
			</form>
		</div>
	</div>
	<script type="text/javascript">
		layui.use(['upload'],function(){
			$ = layui.jquery;

			upload = layui.upload;
			upload.render({
				elem: "#up",
				url: "/index.php/index/index/upload_img",
				done: function(res,title){
					if(res.code > 0){
						return layer.msg("上传失败，"+res.msg);
					}else{
						$("#demo").html('<img style="width:100px;height:100px;" src="'+ res.data +'" class="layui-upload-img"><input type="hidden" id="license" value="'+res.data+'"/>');
					}
				}
			});
		});
		$("#submit").click(function(){
			var school_name = $("#school_name").val();
			if(!school_name){
				alert('请输入企业(学校)名');
				return false;
			}
			var name = $("#name").val();
			if(!name){
				alert('请输入联系人');
				return false;
			}
			var phone = $("#phone").val();
			if(!phone){
				alert('请输入联系手机');
				return false;
			}
			var license = $("#license").val();
			if(!license){
				alert('请上传证件');
				return false;
			}
			$.post("/index.php/index/my/teacher_json",{
				school_name:school_name,
				name:name,
				phone:phone,
				license:license
			},function(res){
				if(res.code != 0){
					alert(res.msg);
					return false;
				}
				alert('申请成功，等待审核');
				window.location.href = '/index.php/index/my/index';
			},'json');
		})
	</script>
{include file="public/tail" /}